<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
	<script type="text/javascript">
        /**
		 *  查看订单详情
         */
        function detailInfo(id){
            $.ajax({
                type: "POST",
                dataType: "JSON",
                url: "${basePath}/back/orders/getOrdersObject.sjson",
                data: {ordersId:id},
                success: function(result){
                    var data = JSON.parse(result.data);
                    /**重置详情页中所有html展示信息**/
                    resetDetailTable("detailTable");
                    /**设置展示信息**/
                    var orders = data.shopOrders;
                    var customer = data.basicCustomer;
                    var shopInfo = data.shopShopinfo;
                    var egList = data.egList;
                    if(customer!=null&&customer!=""){
                        $("#d_customerName").html(customer.loginName);
                    }
                    /**发票信息*/
                    if(orders.invoiceType=="3"){
                        $(".zengZhi").removeAttr("style");
                        $(".puTong").attr("style","display:none;");
                        $("#d_invoiceType").html("增值税发票");
                        $("#d_cNFInvoice").html(orders.companyNameForInvoice);
                        $("#d_taxpayerNumber").html(orders.taxpayerNumber);
                        $("#d_addressForInvoice").html(orders.addressForInvoice);
                        $("#d_phoneForInvoice").html(orders.phoneForInvoice);
                        $("#d_openingBank").html(orders.openingBank);
                        $("#d_bankAccountNumber").html(orders.bankAccountNumber);
                    }else if(orders.invoiceType=="2"){
                        $(".puTong").removeAttr("style");
                        $(".zengZhi").attr("style","display:none;");
                        $("#d_invoiceType").html("普通发票");
                        $("#d_cNFInvoice").html(orders.companyNameForInvoice);
                        $("#d_invoiceInfo").html(orders.invoiceInfo);
                    }else{
                        $(".zengZhi").attr("style","display:none;");
                        $(".puTong").attr("style","display:none;");
                        $("#d_invoiceType").html("默认");
                    }
                    /**发票信息*/
                    $("#d_shopName").html(shopInfo.shopName);
                    $("#d_shopAddress").html(shopInfo.address);
                    $("#d_postCode").html(shopInfo.postCode);
                    if(orders.createTime !=""&&orders.createTime!=undefined){
                        $("#d_createTime").html(new Date(orders.createTime).Format("yyyy-MM-dd hh:mm:ss"));
                    }
                    $("#d_ordersNo").html(orders.ordersNo);
                    $("#d_consignee").html(orders.consignee);
                    $("#d_email").html(orders.email);
                    $("#d_address").html(orders.address);
                    $("#d_phone").html(orders.phone);
                    $("#d_mobilePhone").html(orders.mobilePhone);
                    /**三级返利金额**/
                    $("#d_upRatioAmount").html(orders.rebateAmount);
                    $("#d_secRatioAmount").html(orders.secRebateAmount);
                    $("#d_thiRatioAmount").html(orders.thiRebateAmount);
                    //支付方式展示
                    var payModeName="";
                    if(orders.payMode==1){
                        payModeName= "支付宝";
                    }else if(orders.payMode==2){
                        payModeName= "微信支付";
                    }else if(orders.payMode==3){
                        payModeName= "网银支付";
                    }else if(orders.payMode==4){
                        payModeName= "余额支付";
                    }else if(orders.payMode==5){
                        payModeName= "快钱支付";
                    }else if(orders.payMode==6){
                        payModeName= "货到付款";
                    }else if(orders.payMode==7){
                        payModeName= "金币抵扣";
                    }else if(orders.payMode==8){
                        payModeName= "支付宝（扫描）";
                    }else{
                        payModeName= "--";
                    }
                    $("#d_payMode").html(payModeName);
                    if(orders.sendType=="1"){//配送方式
                        $("#d_sendType").html("快递公司");
                    }else if(orders.sendType=="2"){
                        $("#d_sendType").html("同城快递");
                    }else{
                        $("#d_sendType").html("线下自取");
                    }
                    $("#d_productSumNumber").html(orders.totalAmount);
                    $("#d_changeAmount").html(orders.changeAmount);
                    $("#d_orderCouponAmount").html(orders.orderCouponAmount);
                    $("#d_userCoin").html(orders.userCoin);
                    $("#d_virtualCoinNumber").html(orders.virtualCoinNumber);
                    if(orders.orderSource=="1"){
                        $("#d_orderSource").html("正常购物pc下单");
                    }else if(orders.orderSource=="2"){
                        $("#d_orderSource").html("pc团购下单");
                    }else if(orders.orderSource=="3"){
                        $("#d_orderSource").html("手机web下单");
                    }else if(orders.orderSource=="4"){
                        $("#d_orderSource").html("手机团购下单");
                    }else if(orders.orderSource=="5"){
                        $("#d_orderSource").html("微信下单");
                    }else if(orders.orderSource=="6"){
                        $("#d_orderSource").html("微信团购下单");
                    }else if(orders.orderSource=="7"){
                        $("#d_orderSource").html("APP IOS下单");
                    }else if(orders.orderSource=="8"){
                        $("#d_orderSource").html("APP ANDROID下单");
                    }else if(orders.orderSource=="9"){
                        $("#d_orderSource").html("抢购PC下单");
                    }else if(orders.orderSource=="10"){
                        $("#d_orderSource").html("抢购PHONE下单");
                    }else if(orders.orderSource=="11"){
                        $("#d_orderSource").html("抢购微信下单");
                    }else if(orders.orderSource=="12"){
                        $("#d_orderSource").html("抢购APP下单");
                    }else if(orders.orderSource=="13"){
                        $("#d_orderSource").html("组合购PC下单");
                    }else if(orders.orderSource=="14"){
                        $("#d_orderSource").html("组合购PHONE下单");
                    }else if(orders.orderSource=="15"){
                        $("#d_orderSource").html("组合购微信下单");
                    }else if(orders.orderSource=="16"){
                        $("#d_orderSource").html("组合购APP下单");
                    }else if(orders.orderSource=="17"){
                        $("#d_orderSource").html("积分商城PC下单");
                    }else if(orders.orderSource=="18"){
                        $("#d_orderSource").html("积分商城PHONE下单");
                    }else if(orders.orderSource=="19"){
                        $("#d_orderSource").html("积分商城微信下单");
                    }else if(orders.orderSource=="20"){
                        $("#d_orderSource").html("积分商城APP下单");
                    }
                    var zk = data.zk;
                    if(zk == null){
                        zk = "无折扣";
                    }else{
                        zk += "折";
                    }
                    $("#d_zk").html(zk);
                    $("#d_payNumber").html(orders.finalAmount);
                    $("#d_membersDiscountPrice").html(orders.membersDiscountPrice);
                    $("#d_sendNumber").html(orders.freight);
                    if(orders.settlementStatus=="0"){
                        $("#d_settlementStatus").html("<font class='color_002'>未付款</font>");
                    }else if(orders.settlementStatus=="1"){
                        $("#d_settlementStatus").html("<font class='color_001'>已付款</font>");
                    }
                    if(orders.ordersState=="0"){
                        $("#d_ordersState").html("生成订单");
                    }else if(orders.ordersState=="3"){
                        $("#d_ordersState").html("正在配货");
                    }else if(orders.ordersState=="4"){
                        $("#d_ordersState").html("已经发货");
                    }else if(orders.ordersState=="5"){
                        $("#d_ordersState").html("待评价");
                    }else if(orders.ordersState=="6"){
                        $("#d_ordersState").html("已取消");
                    }else if(orders.ordersState=="7"){
                        $("#d_ordersState").html("异常订单");
                    }else if(orders.ordersState=="9"){
                        $("#d_ordersState").html("已评价");
                    }
                    /**物流信息**/
                    var content =  data.data;
                    var shipping = data.shopShipping;
                    var status = data.status;
                    $("#express").html("");
                    var expressHtml='<tr><td>时间</td><td>动态信息</td></tr>';
                    if(shipping!=null&&content!=null){
                        $(".wuLiu").removeAttr("style");
                        $("#expressDiv").attr("style","");
                        $("#expressTable").attr("style","");
                        /**物流过程信息**/
                        var expressData =  content;
                        /**当前物流状态**/
                        var state = data.state;
                        /**物流公司简称**/
                        var com = data.com;
                        /**物流单号**/
                        var nu = data.nu;
                        for(var i=0;i<expressData.length;i++){
                            /**时间**/
                            var time = expressData[i].time;
                            var location = expressData[i].location;
                            /**内容**/
                            var context = expressData[i].context;
                            expressHtml+='<tr><td>'+time+'<\/td><td>'+context+'<\/td><\/tr>';
                        }
                        if(state==0){
                            $("#expressTitle").html("<font color='green'style='font-weight: bold; size: 12px;'>卖家已发货</font>");
                        }else if(state==1){
                            $("#expressTitle").html("<font color='green'style='font-weight: bold; size: 12px;'>快递公司已接收</font>");
                        }else if(state==2){
                            $("#expressTitle").html("<font color='green'style='font-weight: bold; size: 12px;'>寄送过程中</font>");
                        }else if(state==3){
                            $("#expressTitle").html("<font color='green'style='font-weight: bold; size: 12px;'>已签收</font>");
                        }else if(state==4){
                            $("#expressTitle").html("<font color='green'style='font-weight: bold; size: 12px;'>已退签</font>");
                        }else if(state==5){
                            $("#expressTitle").html("<font color='green'style='font-weight: bold; size: 12px;'>同城派件中</font>");
                        }else if(state==6){
                            $("#expressTitle").html("<font color='green'style='font-weight: bold; size: 12px;'>退回中</font>");
                        }else{
                            $("#expressTitle").html("");
                        }
                        $("#expressMessager").html("<font color='green' style='size: 12px;'>"+shipping.deliveryCorpName+"</font>");
                        $("#expressInternet").html("<font color='green' style='size: 12px;'>"+shipping.deliveryUrl+"</font>");
                        $("#expressNo").html("<font color='green' style='size: 12px;'>"+shipping.deliverySn+"</font>");
                        $("#express").html(expressHtml);
                    }else if(shipping!=null){
                        $(".wuLiu").removeAttr("style");
                        $("#expressDiv").attr("style","");
                        $("#express").html("");
                        $("#expressTable").attr("style","display: none;");
                        $("#expressMessager").html("");
                        $("#expressTitle").html("");
                        $("#expressMessager").html("<font color='green' style='size: 12px;'>"+shipping.deliveryCorpName+"</font>");
                        $("#expressInternet").html("<font color='green' style='size: 12px;'>"+shipping.deliveryUrl+"</font>");
                        $("#expressNo").html("<font color='green' style='size: 12px;'>"+shipping.deliverySn+"</font>");
                        $("#expressTitle").html("<font color='red' style='font-weight: bold; size: 12px;'>暂无</font>");
                    }else{
                        $(".wuLiu").attr("style","display:none;");
                        $("#express").html("");
                        $("#expressMessager").html("");
                        $("#expressTitle").html("");
                        $("#expressDiv").attr("style","display: none;");
                    }
                    if(egList!=null&&egList!=""){
                        var html="<tr class='titlebg'><td align='center' colspan='8' style='font-weight: bolder;'> 评价信息<\/td><\/tr>";
                        html += "<tr><td align='center' width='150px'>商品名称<\/td><td align='center' width='150px'>评价内容<\/td><\/tr>";
                        for(var i=0;i<egList.length;i++){
                            html+="<tr><td align='center' width='150px'>"+egList[i].productFullName+"<\/td><td align='center' width='150px'>"+egList[i].content+"<\/td><\/tr>";
                        }
                        $("#order_evaluate").html(html);
                    }
                }
            });
        }
	</script>
	<div  class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog" style="width:70%">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<h5 class="modal-title" id="myModalLabel">订单详情</h5>
				</div>
				<div class="modal-body">
					<table id="detailTable" align="center" class="addOrEditTable table table-bordered" style="width:100%;">
						<tr class="titlebg">
							<td colspan='8' align='center' style="font-weight: bolder;">订单信息</td>
						</tr>
						<tr>
							<td class="toright_td" width="90px">会员名称:&nbsp;&nbsp;</td><td id="d_customerName" ></td>
							<td class="toright_td" width="90px">订单号:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_ordersNo"></span></td>
							<td class="toright_td" width="90px">订单来源:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_orderSource"></span></td>
							<td class="toright_td" width="90px">下单时间:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_createTime"></span></td>
						</tr>
						<tr>
							<td class="toright_td">付款状态:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_settlementStatus"></span></td>
							<td class="toright_td">支付方式:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_payMode"></span></td>
							<td class="toright_td">订单状态:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_ordersState"></span></td>
							<td class="toright_td">配送方式:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_sendType"></span></td>
						</tr>
						<tr class="titlebg">
							<td colspan='8' align='center' style="font-weight: bolder;">结算信息</td>
						</tr>
						<tr>
							<td class="toright_td">商品总金额:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_productSumNumber"></span>&nbsp;元</td>
							<td class="toright_td">会员节省:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_membersDiscountPrice"></span>&nbsp;元</td>
							<td class="toright_td">使用金币:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_userCoin"></span>&nbsp;个</td>
							<td class="toright_td">金币抵扣:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_changeAmount"></span>&nbsp;元</td>
						</tr>
						<tr>
							<td class="toright_td">优惠券抵扣:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_orderCouponAmount"></span>&nbsp;元</td>
							<td class="toright_td">赠送金币:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_virtualCoinNumber"></span>&nbsp;个</td>
							<td class="toright_td">折扣:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_zk"></span></td>
							<td class="toright_td">运费:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_sendNumber"></span>&nbsp;元</td>
						</tr>
						<tr>
							<td class="toright_td">应付金额:&nbsp;&nbsp;</td><td colspan='7'>&nbsp;&nbsp;<span id="d_payNumber"></span>&nbsp;元</td>
						</tr>
						<tr>
							<td class="toright_td">一级返利:&nbsp;&nbsp;</td><td >&nbsp;&nbsp;<span id="d_upRatioAmount"></span>&nbsp;元</td>
							<td class="toright_td">二级返利:&nbsp;&nbsp;</td><td >&nbsp;&nbsp;<span id="d_secRatioAmount"></span>&nbsp;元</td>
							<td class="toright_td">三级返利:&nbsp;&nbsp;</td><td colspan='3'>&nbsp;&nbsp;<span id="d_thiRatioAmount"></span>&nbsp;元</td>
						</tr>
						<tr class="titlebg">
							<td colspan='8' align='center' style="font-weight: bolder;">收货人信息</td>
						</tr>
						<tr>
							<td class="toright_td">收货人姓名:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_consignee"></span></td>
							<td class="toright_td">手机:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_mobilePhone"></span></td>
							<td class="toright_td">详细地址:&nbsp;&nbsp;</td><td colspan='3'>&nbsp;&nbsp;<span id="d_address"></span></td>
						</tr>
						<tr class="titlebg">
							<td colspan='8' align='center' style="font-weight: bolder;">店铺信息</td>
						</tr>
						<tr>
							<td class="toright_td">店铺名称:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_shopName"></span></td>
							<td class="toright_td">店铺邮编:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_postCode"></span></td>
							<td class="toright_td">店铺地址:&nbsp;&nbsp;</td><td colspan='3'>&nbsp;&nbsp;<span id="d_shopAddress"></span></td>
						</tr>
						<tr class="titlebg">
							<td colspan='8' align='center' style="font-weight: bolder;">发票信息&nbsp;&nbsp;(<span id="d_invoiceType"></span>)</td>
						</tr>
						<tr>
							<td class="toright_td">发票抬头:&nbsp;&nbsp;</td><td colspan='3'>&nbsp;&nbsp;<span id="d_cNFInvoice"></span></td>
							<td class="toright_td">发票内容:&nbsp;&nbsp;</td><td colspan='3'>&nbsp;&nbsp;<span id="d_invoiceInfo"></span></td>
						</tr>
						<tr class="zengZhi">
							<td class="toright_td">纳税人识别号:&nbsp;&nbsp;</td><td colspan='3'>&nbsp;&nbsp;<span id="d_taxpayerNumber"></span></td>
							<td class="toright_td">地址:&nbsp;&nbsp;</td><td colspan='3'>&nbsp;&nbsp;<span id="d_addressForInvoice"></span></td>
						</tr>
						<tr class="zengZhi">
							<td class="toright_td">账号:&nbsp;&nbsp;</td><td colspan='2'>&nbsp;&nbsp;<span id="d_bankAccountNumber"></span></td>
							<td class="toright_td">开户行:&nbsp;&nbsp;</td><td colspan='2'>&nbsp;&nbsp;<span id="d_openingBank"></span></td>
							<td class="toright_td">电话:&nbsp;&nbsp;</td><td>&nbsp;&nbsp;<span id="d_phoneForInvoice"></span></td>
						</tr>
						<tr class="wuLiu titlebg">
							<td colspan='8' align='center' style="font-weight: bolder;">物流信息</td>
						</tr>
						<tr class="wuLiu">
							<td class="toright_td">物流单号:&nbsp;&nbsp;</td><td class="toleft_td" colspan='3'>&nbsp;&nbsp;<span id="expressNo"></span></td>
							<td class="toright_td">物流公司:&nbsp;&nbsp;</td><td class="toleft_td" colspan='3'>&nbsp;&nbsp;<span id="expressMessager"></span></td>
						</tr>
						<tr class="wuLiu">
							<td class="toright_td">物流公司网址:&nbsp;&nbsp;</td><td class="toleft_td" colspan="7">&nbsp;&nbsp;<span id="expressInternet"></span></td>
						</tr>
						<tr class="wuLiu">
							<td class="toright_td">物流动态:&nbsp;&nbsp;</td><td class="toleft_td" colspan="7">&nbsp;&nbsp;<span id="expressTitle"></span></td>
						</tr>
					</table>
					<table id="order_evaluate" align="center" class="addOrEditTable" style="width:100%;"></table>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
